package com.yjjxt

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Hello01Spark {
  def main(args: Array[String]): Unit = {

    //创建配置文件
    val sparkConf = new SparkConf().setMaster("local").setAppName("WordCount")
    val sparkContext = new SparkContext(sparkConf)
    val value: RDD[(String, Int)] = sparkContext.textFile("src/main/resources/user.log").flatMap(_.split(" ")).map((_, 1)).reduceByKey(_ + _)
    value.foreach(println)
    println(value.count())

  }
}
